home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj8404.arc
/
SEARCH2.BAS
< prev
next >
Wrap
BASIC Source File
|
1986-09-14
|
896b
|
32 lines
'$$$$$$$$$$$$$$
'Subroutine
'$$$$$$$$$$$$$$
'
' This is the modified sequential search subroutine.
' Input is the table in which to look up (ITABLE),
' the number of entries in the table (NTABLE), and
' the number whose index is to be found (JKEY).
' Output is the index (INDX) such that
' TABLE(INDX) = JKEY
'
' MODIFIED SEQUENTIAL SEARCH
'
8000 rem Start.
REM CMP cmp = 0
'
for i. = 11 to ntable+10 step 10
REM CMP cmp = cmp + 1.
if (ntable <= i.) then goto 8010
if (itable(i.) < jkey) then goto 8020
'
' ITABLE(i.) < jkey; go back and look through last 10 entries.
'
8010 jstart. = i.-10
for j. = jstart. to i.
REM CMP cmp = cmp + 1.
if (itable(j.) = jkey) then indx=j.: return
next j.
'
8020 next i.
return